package com.ccp.dev.qbdms.controller;

import com.ccp.dev.core.basic.annotion.Action;
import com.ccp.dev.core.basic.consts.UrlConstants;
import com.ccp.dev.core.basic.internationalization.SysBaseController;
import com.ccp.dev.core.basic.web.query.QueryFilter;
import com.ccp.dev.core.util.RequestUtil;
import com.ccp.dev.core.util.log.SysAuditThreadLocalHolder;
import com.ccp.dev.qbdms.consts.ZhiLiangConst;
import com.ccp.dev.qbdms.service.WQbdQualitymanageService;
import java.util.Date;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
/**
 * 请将此名称添加到日志开关
 */
@Action(customModel = "质量管理体系统计统计")
@RequestMapping("/qbdms/wQbdQualitymanageStatistics")
public class WQbdQualitymanageStatisticsController extends SysBaseController {

  @Resource
  private WQbdQualitymanageService wQbdQualitymanageService;

  /**
   * 功能描述: 跳转到首页
   *
   * @return: java.lang.String
   * @auther: 于金
   * @date: 2020-05-12 10:39:53
   */
  @RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX +"/wQbdQualitymanageStatisticsCharts")
  @Action(description = "跳转到质量管理体系统计首页", exectype = "页面跳转日志")
  public String viewList(HttpServletRequest request, ModelMap modelMap) {
    QueryFilter queryFilter = new QueryFilter(request, true);
    String nowyear = DateFormatUtils.format(new Date(), "yyyy");
    modelMap.put("nowyear",nowyear);
    // 添加通用查询条件
    return "wQbdQualitymanageStatistics/wQbdQualitymanageStatisticsCharts";
  }
  @RequestMapping("/getChartData")
  @ResponseBody
  @Action(description = "查询数据信息", exectype = "查询日志")
  public Object getChartData(HttpServletRequest request, ModelMap modelMap) throws Exception{
    QueryFilter queryFilter = new QueryFilter(request, true);
    // 添加通用查询条件
    ZhiLiangConst.addQueryFilter(queryFilter);
    Map<String, Object> fAudittypeSta = wQbdQualitymanageService.fAudittypeSta(queryFilter);
    Map<String, Object> fUnqualifiednatureSta = wQbdQualitymanageService.fUnqualifiednatureSta(queryFilter);
    Map<String, Object> fTrialunitnameSta = wQbdQualitymanageService.fTrialunitnameSta(queryFilter);
    Map<String, Object> getFstandardclause = wQbdQualitymanageService.fstandardclauseSta(queryFilter);
    Map<String, Object> fsubstandardclauses = wQbdQualitymanageService.fstandardclauseSuSta(queryFilter);
    modelMap.put("fAudittypeSta",fAudittypeSta);
    modelMap.put("fUnqualifiednatureSta",fUnqualifiednatureSta);
    modelMap.put("fTrialunitnameSta",fTrialunitnameSta);
    modelMap.put("getFstandardclause",getFstandardclause);
    modelMap.put("fsubstandardclauses",fsubstandardclauses);
    return success(modelMap);
  }
}
